package com.atkxp.dao.impl;

import com.atkxp.dao.OrderDao;
import com.atkxp.domain.Order;

import java.util.List;

/**
 * @author user
 * @declaration
 * @create 2022/10/5-10:03
 */
public class OrderDaoImpl extends BaseDao<Order> implements OrderDao {
    @Override
    public int saveOrder(Order order) {
        String sql = "insert into t_order(order_id, create_time, price, status, user_id) values(?, ?, ?, ?, ?)";
        return update(sql, order.getOrder_id(), order.getCreate_time(), order.getPrice(), order.getStatus(), order.getUser_id());
    }

    @Override
    public List<Order> queryOrders() {
        String sql = "select * from t_order";
        return getAllInstance(sql);
    }

    @Override
    public int changeOrderStatus(String orderId, int status) {
        String sql = "update t_order set status = ? where order_id = ?";
        return update(sql, status, orderId);
    }

    @Override
    public List<Order> queryOrderByUserId(int userid) {
        String sql = "select * from t_order where user_id = ?";
        return getAllInstance(sql, userid);
    }
}
